package com.likeycy.my;

import com.likeycy.my.circle.MyCircleLinkedList;
import com.likeycy.my.circle.MyCircleSinglyLinkedList;
import com.likeycy.my.tool.AssertUtils;

/**
 * @ClassName: TestMyLinkedList
 * @Description: 测试自定义的链表
 * @Author: sodagreen
 * @Date: 2021/3/3 22:51
 * @Version: 1.0
 */
public class TestMyLinkedList {

    public static void testMyLinkedList(List<Integer> list) {
        list.add(11);
        list.add(22);
        list.add(33);
        list.add(44);

        list.add(0,55);
        list.add(2, 66);
        list.add(list.size(), 77);

        list.remove(0);
        list.remove(2);
        list.remove(list.size() - 1);

        AssertUtils.test(list.indexOf(44) == 3);
        AssertUtils.test(list.indexOf(22) == List.ELEMENT_NOT_FOUND);
        AssertUtils.test(list.contains(33));
        AssertUtils.test(list.get(0) == 11);
        AssertUtils.test(list.get(1) == 66);
        AssertUtils.test(list.get(list.size() - 1) == 44);
        System.out.println(list);
    }

    public static void main(String[] args) {
        testMyLinkedList(new MyLinkedList<>());
        testMyLinkedList(new MyCircleSinglyLinkedList<>());
        testMyLinkedList(new MyCircleLinkedList<>());
    }
}
